// 操作符枚举
export enum FilterOperateEnum {
  AND = 1, // 逻辑与&&
  OR = 2, //逻辑或||
  EQUAL_TO = 3, // 等于
  NOT_EQUAL_TO = 4, // 不等于
  LESS_THAN = 5, // 小于
  LESS_THAN_EQUAL_TO = 6, // 小于等于
  GREATER_THAN = 7, // 大于
  GREATER_THAN_EQUAL_TO = 8, // 大于等于
  START_AT = 9, // 开始于
  END_AT = 10, // 结束于
  CONTAIN = 11, // 包含
  NOT_CONTAIN = 12, // 不包含
  START_OR_REVERT_AT = 13, // 以...开始或以反转开始
}

// 排序枚举
export enum SortConditionEnum {
  asc = 0,
  desc = 1,
}

// 排序条件
export class SortCondition {
  field: string;
  sort: SortConditionEnum;
  constructor(field: string, sort: SortConditionEnum) {
    this.field = field;
    this.sort = sort;
  }
}

// 分页信息
export class PageCondition {
  pageIndex: number;
  pageSize: number;
  sortConditions: SortCondition[];
  constructor(pageIndex: number = 1, pageSize: number = 10, sortConditions: SortCondition[] = []) {
    this.pageIndex = pageIndex;
    this.pageSize = pageSize;
    this.sortConditions = sortConditions;
  }
}

export class FilterRule {
  field: string;
  value: any;
  operate: FilterOperateEnum;
  constructor(field: string, value: any, operate: FilterOperateEnum) {
    this.field = field;
    this.value = value;
    this.operate = operate;
  }
}

export class FilterGroup {
  filterRule: FilterRule[];
  operate: FilterOperateEnum = FilterOperateEnum.AND;
  constructor(rules: FilterRule[], operate: FilterOperateEnum) {
    this.filterRule = rules;
    this.operate = operate;
  }
}

export class Filter {
  groups: FilterGroup[];
  rules: FilterRule[];
  constructor(filterGroups: FilterGroup[], filterRules: FilterRule[]) {
    this.groups = filterGroups;
    this.rules = filterRules;
  }
}

export class PageRequest {
  pageCondition: PageCondition;
  filter: Filter;
  constructor(pageCondition: PageCondition, filter: Filter) {
    this.pageCondition = pageCondition;
    this.filter = filter;
  }
}
